import { forBindEventThis } from '@/components/global_comps';
import { active_type_dataMana } from './cla_active_type_dataMana';
import type { active_type_props } from './cla_active_type_props';
import { cur_event_check } from '@/components/global_comps/Classes/cla_event_check';
import { uni_type } from '../../uni_type/DataDefine/sourceData';
import { self_event_click_me } from '@/components/global_comps/Classes/listenEvent_mana/Types';

const active_type_operateTag = 'active_type_operate';

export class active_type_operate extends active_type_dataMana {
  get [Symbol.toStringTag]() {
    return active_type_operateTag;
  }

  constructor(props: active_type_props) {
    super(props);

    forBindEventThis(this);

    this.eventM.addEventListen(
      this.dom_border,
      'click',
      this.eventBind.border_check_chi_click
    );
  }

  /**
   * 点击 主体元素 测定 触发元素 的
   * class 是否 是 uni_type
   *
   * 是
   *
   * 派送 uni_type 的 自定义 事件 click_me
   */
  border_check_chi_click(event: MouseEvent) {
    if (
      cur_event_check
        .set_cur_event(event)
        .left_click()
        .is_chi_class_emit(uni_type).result === false
    ) {
      return;
    }

    let cur_uni_type = cur_event_check.special_class_dom!;

    const cur_self_event_click_me = new Event(self_event_click_me);

    cur_uni_type.dispatchEvent(cur_self_event_click_me);
  }
}
